%hr.section
%h3 History
-unless object.versions.empty?
  .block
    -first = true
    -versions = object.versions.all + [object]
    -prev_version = versions.shift
    .block
      Created at
      =display_time(object.created_at)
      \:
      =render :partial => "base/compact_model", :locals => {:model => object.model, :object => prev_version}
    -versions.each do |version|
      .block
        Updated at
        =display_time(version.updated_at)
        \:
        =render :partial => "base/model_diff", :locals => {:first => prev_version, :second => version}
        -prev_version = version
    -object.model.relationships.each do |relation|
      -if relation.instance_of?(DataMapper::Associations::ManyToMany::Relationship) && (relation.through.child_model::Version rescue false)
        -through = relation.through
        %h4
          Connected
          =relation.field.humanize
        -through.child_model::Version.where(through.child_key.first.name => object.id).each do |version|
          .block
            -other_id = relation.via.child_key.find(version)
            -other = relation.child_model.find(other_id)
            -if version.is_destroyed
              Disconnected at
            -else
              Updated at
            =display_time(version.updated_at)
            -if other
              =link_to other.display_name, url_for(other)
            -else
              (deleted, id =
              =other_id
              )
